package ${package}.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.appopay.common.base.controller.BaseController;
import com.appopay.common.Result;
import org.springframework.data.jpa.domain.Specification;
import org.apache.commons.lang3.StringUtils;
import ${package}.entity.${TableName};
import ${package}.service.${TableName}Service;
import com.appopay.common.base.query.QueryWrapper;
/**
 * @author ${author}
 * @since ${date}
 * @description：${tableComment!}
 */
@RestController
@RequestMapping("/api/${tableName}")
public class ${TableName}Controller extends BaseController<${TableName}Service, ${TableName}>{
    @RequestMapping("page")
    public Result page(Pageable page, ${TableName} pojo) {

QueryWrapper<${TableName}> queryWrapper = new QueryWrapper<>();
<#list  columns as field>
    <#if field.javaType=="String">
        if (StringUtils.isNotBlank(pojo.get${field.ColumnName!}())) {
        queryWrapper.like("${field.columnName!}", pojo.get${field.ColumnName!}());
        }
    </#if>
</#list>

        Page<${TableName}> pageData = this.baseService.page(page,queryWrapper);
        return Result.success(pageData);
    }

@RequestMapping("upsert")
public Result upsert(@RequestBody ${TableName} pojo) {
${TableName} ${tableName} = this.baseService.saveOrUpdate(pojo);
return Result.success(${tableName});
}

}
